package org.ndx.jsg.input;

import java.io.File;

import org.apache.tika.metadata.Metadata;
import org.ndx.jsg.FileInfos;
import org.ndx.jsg.util.JsgException;

/**
 * Given a file, builds its file infos, provided file mime type is correct.
 * @author ndx
 *
 */
public interface FileInfosBuilder {
	public static class BadFile extends JsgException {
		public BadFile(File f, Metadata metadata, String message, FileInfosBuilder builder) {
			super("unable to create infos from "+f+" of type "+metadata.get(Metadata.CONTENT_TYPE)+" due to "+message+" for builder "+builder.getClass().getName());
		}
	}

	/**
	 * Get file info for input file. May be invoked with an incorrect input file. In such a case, 
	 * @param f input file
	 * @param relativePath path from file relatively to its input file, given as a string with path separated using {@link File#separator}
	 * @param metadata metadata associated to this file
	 * @return a {@link FileInfos} implementation, or null if not the right type
	 */
	FileInfos getFileInfo(File f, String relativePath, Metadata metadata);

}
